<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<%-- <script src="${pageContext.request.contextPath}/js/jquery3.3.1.js"></script> --%>
<%-- <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet"> --%>
<%-- <link href="${pageContext.request.contextPath}/css/bootstrap-theme.min.css" rel="stylesheet"> --%>
<%-- <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script> --%>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="${pageContext.request.contextPath }/JS/jquery-1.11.0.min.js"></script>
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <link href="${pageContext.request.contextPath }/css/flowersingle.css" rel="stylesheet" type="text/css" />
<title>上架商品</title>
<style type="text/css">
div{
float:left;
}
</style>
</head>

<body>

<div id = "my_updown_out" class = "" style = "display:none;min-width:1349px;
height:1000px;background-color: rgba(0,0,0,0.4);position: fixed;z-index: 1000;">



<!-- 中心开始 -->
<div id = "" class = "" style = "width:700px;height:600px;background-color: white;border-radius:5px;
margin-left: 320px;margin-top: 10px;">
<!-- 	导航开始 -->
	<div id = "" class = "" style = "width:100%;">
		<nav style = "" class = "navbar navbar-inverse " role = "navigation">
			<div id = "" class = "">
			<div class="navbar-header">
		        <div class="navbar-brand" href="#" style = "color:#f73020;">上架</div>
		    </div>
		    <div class="navbar-header">
		       <a href = "#"onclick = "$('#my_updown_out').css('display','none')"><div class="navbar-brand" href="#" style = "color:#f73020;">返回</div></a> 
		    </div>
			</div>
		</nav>	
	</div><!-- 	导航结束 -->
	
<!-- 	表单开始 -->
	<form action="${pageContext.request.contextPath }/UpCommodityServlet" id = "updown_out_form" method = "post" enctype="multipart/form-data">
	<div id = "" class = "" style = "width: 90%;margin-left: 30px;">
		<table class = "table table-hover">
		<tr>
		    <td>
		    	<div id = "" class = "" style = "width:140px;height:100px;">
		    		<img alt="" src="${pageContext.request.contextPath }/img/quesheng.jpg" id = "updown_out_img" style = "width:100%;height:100%;">
		    	</div>
		    </td>
		    <td>
				<input type = "file" id = "cmdy_img_file"  class = "form-control" name = "img" onchange="showPreview(this)">
			</td>
		  </tr>
		  <tr>
		    <td>商品名称</td>
		    <td>
				<div class="input-group">
					<span class="input-group-btn">
						<button class="btn btn-default" type="button">
							&nbsp
						</button>
					</span>
					<input type="text" class="form-control" id = "updown_out_cmdyname" name = "cmdyname">
				</div>
			</td>
		  </tr>
		  <tr>
		    <td>商品价格</td>
		    <td>
				<div class="input-group">
					<span class="input-group-btn">
						<button class="btn btn-default" type="button">
							&nbsp
						</button>
					</span>
					<input type="text" class="form-control" name = "price" id = "updown_out_price">
				</div>
			</td>
		  </tr>
		  <tr>
		    <td>商品描述</td>
		    <td>
		    	<textarea rows="" cols="" placeholder = "" class = "form-control" style = "" name = "detail"></textarea>
		    </td>
		  </tr>
		  <tr>
		    <td>类型</td>
		    <td>
		    	<select class = "form-control" name = "type" >
		    		<option>零食</option>
		    		<option>日用品</option>
		    		<option>手机数码</option>
		    		<option>衣服</option>
		    	</select>
		    </td>
		  </tr>
		  <tr>
		    <td>库存</td>
		    <td>
		    	<div class="input-group">
					<span class="input-group-btn">
						<button class="btn btn-default" type="button">
							&nbsp
						</button>
					</span>
					<input type="text" class="form-control" id = "updown_out_inventory" name = "inventory">
				</div>
		    </td>
		  </tr>
		  <tr>
		    <td colspan="2">
		    	<input type = "hidden" id = "shoppower" class = "" value = "${shop.shoppower }" name = "">
		    	<button type="button" class="btn btn-default btn-lg btn-block" onclick = "upCommodity()">上架</button>
		    </td>
		  </tr>
		</table>
<script type="text/javascript">
function upCommodity(){
	var inventory = $("#updown_out_inventory").val()
	var cmdyname = $("#updown_out_cmdyname").val()
	var price = $("#updown_out_price").val()
	var file = $("#cmdy_img_file").val()
	
	
	if($("#shoppower").val()=="1"){
		if(isNaN(inventory)||isNaN(price)||file==""||cmdyname==""||inventory == "" || price == ""){
			alert("请检查输入")
		}else{
			$("#updown_out_form").submit()
			alert("上架成功")
		}
	}else{
		alert("你没有权限上架")
	}
}
</script>
	
	</div></form><!-- 	表单结束 -->
	
	
	
	
	
</div><!-- 中心结束 -->



</div>

<!-- 图片的当页显示 -->
<script type="text/javascript">
function showPreview(source) {
    var file = source.files[0];
    if(window.FileReader) {
        var fr = new FileReader();
        fr.onloadend = function(e) {
            document.getElementById("updown_out_img").src = e.target.result; //这个就是图片的流，可以直接展示到页面上
        };
        fr.readAsDataURL(file);
    }
}/* 图片的当页显示 结束*/

</script>


</body>
</html>